package practice;

import java.util.Random;
import java.util.Scanner;

public abstract class FingerGuess {
    public abstract String toString();
    public abstract void finger();

    public void print(){
        System.out.println(toString());
        finger();
        System.out.println();
    }



}
//---------------------------------
class HumanPlayer extends FingerGuess{

    @Override
    public String toString() {

        return "人类玩家：";
    }

    @Override
    public void finger() {
        Scanner stdIn=new Scanner(System.in);
        System.out.print("请出拳：0...石头/1...剪刀/2...布（输入相应数字）");
        int x=stdIn.nextInt();
        switch (x) {
            case 0: System.out.println("你出拳：石头");break;
            case 1: System.out.println("你出拳：剪刀");break;
            case 2: System.out.println("你出拳：布");break;
            default:
                System.out.println("输入越界！！！");break;
        }


    }
}
//-----------------------------------
class Computer extends FingerGuess{

    @Override
    public String toString() {
        return "电脑玩家：";
    }

    @Override
    public void finger() {
        Random rand=new Random();
        int x=rand.nextInt(3);
        switch (x){
            case 0: System.out.println("石头");break;
            case 1: System.out.println("剪刀");break;
            case 2: System.out.println("布");break;
        }

    }
}
